home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 17
/
CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso
/
CUCD
/
Programming
/
DiceSource
/
lib
/
memory
/
malloc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-09-09
|
663b
|
41 lines
/*
* MALLOC.C
*
* (c)Copyright 1992-1997 Obvious Implementations Corp. Redistribution and
* use is allowed under the terms of the DICE-LICENSE FILE,
* DICE-LICENSE.TXT.
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <clib/exec_protos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
extern long *__MemList;
void *
malloc(bytes)
size_t bytes;
{
long *ptr;
if (bytes == 0)
return(NULL);
ptr = AllocMem(bytes + 8, MEMF_PUBLIC);
if (ptr) {
ptr[0] = (long)__MemList;
__MemList = ptr;
ptr[1] = bytes + 8;
ptr += 2;
} else {
errno = ENOMEM;
}
return((void *)ptr);
}